

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.GBaseActivity;
import com.example.administrator.caigou51.control.DialogGoodsBuy;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.card.AddAgainGoodsCard;
import com.example.administrator.caigou51.util.ImageUtil;


public class AddAgainGoodsCardView extends CardItemView<AddAgainGoodsCard> {
 	private Context mContext;
    private TextView textViewTime;
    private TextView textViewState;
    private ImageView imageViewGoods;
    private TextView textViewGoodsName;
    private TextView textViewMoneyIcon;
    private TextView textViewGoodsPrice;
    private ImageView imageViewCar;
    private TextView textViewBZ;
    public AddAgainGoodsCardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public AddAgainGoodsCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public AddAgainGoodsCardView(Context context,
                                    AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }
    @Override
    public void build(final AddAgainGoodsCard card) {
        // TODO Auto-generated method stub
        super.build(card);
        textViewTime = (TextView) findViewById(R.id.textViewTime);
        textViewState = (TextView) findViewById(R.id.textViewState);
        imageViewGoods = (ImageView) findViewById(R.id.imageViewGoods);
        textViewGoodsName = (TextView) findViewById(R.id.textViewGoodsName);
        textViewMoneyIcon = (TextView) findViewById(R.id.textViewMoneyIcon);
        textViewGoodsPrice = (TextView) findViewById(R.id.textViewGoodsPrice);
        imageViewCar = (ImageView) findViewById(R.id.imageViewCar);imageViewCar.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogGoodsBuy.TaskAddCar("1",null,(GBaseActivity)mContext,card.getNoGoodsBean().getItemid(),true);
            }
        });
        textViewBZ = (TextView) findViewById(R.id.textViewBZ);

        textViewTime.setText(card.getNoGoodsBean().getAdd_time());
        int number=Integer.parseInt(card.getNoGoodsBean().getNumber());
        int kucun=Integer.parseInt(card.getNoGoodsBean().getAmount());
        if (number>=kucun)
        {
            textViewState.setText("正在补货中");
            textViewState.setTextColor(getResources().getColor(R.color.color_1ca146));
            imageViewCar.setVisibility(View.GONE);
        }else
        {
            textViewState.setText("有货");
            textViewState.setTextColor(getResources().getColor(R.color.color_fe5858));
            imageViewCar.setVisibility(View.VISIBLE);
        }
        App.displayImageHttpOrFile(card.getNoGoodsBean().getThumb(),imageViewGoods, ImageUtil.OptionsActivity());
        textViewGoodsName.setText(card.getNoGoodsBean().getTitle()+"\n"+card.getNoGoodsBean().getProduct_spec());
        textViewGoodsPrice.setText(card.getNoGoodsBean().getNumber());
        textViewBZ.setText(card.getNoGoodsBean().getInformation());
    }
}
